package com.yizhang.xml.web;

import com.yizhang.xml.dao.UserDao;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: yi.zhang
 * @CreateTime: 2025-06-19 10:49:47
 * @Description: servlet启动
 */
@WebServlet(value = "/myServlet", loadOnStartup = 100)
public class MyServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
        UserDao bean = applicationContext.getBean(UserDao.class);
        bean.transfer();
    }
}
